package com.jxb.test20241216;

import java.util.Stack;

/**
 * 类注释
 *
 * @author jiaobo
 * @date Created in 2024/12/22 21:10
 **/
public class ImplQueueUsingStacks_232 {


    static class MyQueue {
        private static Stack<Integer> inStack;
        private static Stack<Integer> outStack;

        public void push(int x) {
            inStack.push(x);
        }

        public Integer pop() {
            if (outStack.empty()) {
                in2out();
            }
            Integer pop = outStack.pop();
            return pop;
        }

        private void in2out() {
            while (!inStack.isEmpty()) {
                outStack.push(inStack.pop());
            }
        }
    }

}
